//友情链接JS文件
layui.use(['jquery','layer','table','form'],function(){
    var $ = layui.$,
        layer = layui.layer,
        form = layui.form,
        table = layui.table;
    
    $(document).ready(function(){
    	
    
    	$.post("/systemsetup/basicsetup/shortmessage/getShortMessage",{},function(result){
    		if (result.status == 200) {
    			$("#type_id option[value="+result.data["type"]+"]").attr("selected", true);
    			$("#keyid").val(result.data["keyid"]);
    			$("#id").val(result.data["id"]);
    			$("#secret").val(result.data["secret"]);
    			$("#autograph").val(result.data["autograph"]);
    			
    			 form.render('select');
			}
		});
    	
    	
		
    });
    
    
    //监听提交
    form.on('submit(ShortMessage)', function(data){
    	$.post("/systemsetup/basicsetup/shortmessage/updataShortMessage",data.field,function(result){
    		if (result.status == 200) {
    			layer.msg(result.msg);
    			layer.msg(result.msg, {
					icon: 1,
					time: 2000 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					window.location.reload();
				});
    			
			} else {
				layer.msg(result.msg);
			}
    	});
    	return false;
    });
    
    
    form.on('submit(sendShortMessage)', function(data){
    	$.post("/systemsetup/basicsetup/shortmessage/sendShortMessage",data.field,function(result){
    		if (result.status == 200) {
    			layer.msg(result.msg);
    			layer.msg(result.msg, {
					icon: 1,
					time: 2000 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					window.location.reload();
				});
			} else {
				layer.msg(result.msg);
			}
    	});
    	return false;
    });
    
});